package com.tzpay.tzpay.api;

import com.tzpay.tzpay.bean.UserInfo;
import com.tzpay.tzpay.common.ConstValue;
import com.tzpay.tzpay.utils.CryptTool;
import com.tzpay.tzpay.utils.Utils;

/**
 * Description:
 * Created:      [16/3/15]
 * Author:       [Yang]
 **/
public class OrderCreateRequest {

    public String merchantId = UserInfo.getInstance().getMerchantNo();
    public String subMerchantId = UserInfo.getInstance().getSubMerchantNo();
    public String barcode;
    public String orderNo = String.valueOf(System.currentTimeMillis());
    public String orderReqNo = orderNo + "0001";
    public String channel = UserInfo.getInstance().getChannel();
    public String busiType = UserInfo.getInstance().getBusicType();
    public String orderDate = Utils.getTime();
    public String orderAmt;
    public String productAmt;
    public String attachAmt = "0";
    public String goodsName = "测试商品";
    public String storeId = UserInfo.getInstance().getShopId();
    public String backUrl = UserInfo.getInstance().getBackUrl();
    public String ledgerDetail = UserInfo.getInstance().getLedgerDetail();
    public String attach = UserInfo.getInstance().getAttach();
    public String mac;

    public String calculateMac() {
        StringBuilder sb = new StringBuilder();
        sb.append("MERCHANTID=").append(merchantId);
        sb.append("&ORDERNO=").append(orderNo);
        sb.append("&ORDERREQNO=").append(orderReqNo);
        sb.append("&ORDERDATE=").append(orderDate);
        sb.append("&BARCODE=").append(barcode);
        sb.append("&ORDERAMT=").append(orderAmt);
        sb.append("&KEY=").append(UserInfo.getInstance().getMerchantDataKey());//此处是商户的key

        String enMac = "";
        try {
            System.err.println(sb.toString());
            enMac = CryptTool.md5Digest(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return enMac;
    }
    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public String getSubMerchantId() {
        return subMerchantId;
    }

    public void setSubMerchantId(String subMerchantId) {
        this.subMerchantId = subMerchantId;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getOrderReqNo() {
        return orderReqNo;
    }

    public void setOrderReqNo(String orderReqNo) {
        this.orderReqNo = orderReqNo;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getBusiType() {
        return busiType;
    }

    public void setBusiType(String busiType) {
        this.busiType = busiType;
    }

    public String getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(String orderDate) {
        this.orderDate = orderDate;
    }

    public String getOrderAmt() {
        return orderAmt;
    }

    public void setOrderAmt(String orderAmt) {
        this.orderAmt = orderAmt;
    }

    public String getProductAmt() {
        return productAmt;
    }

    public void setProductAmt(String productAmt) {
        this.productAmt = productAmt;
    }

    public String getAttachAmt() {
        return attachAmt;
    }

    public void setAttachAmt(String attachAmt) {
        this.attachAmt = attachAmt;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getBackUrl() {
        return backUrl;
    }

    public void setBackUrl(String backUrl) {
        this.backUrl = backUrl;
    }

    public String getLedgerDetail() {
        return ledgerDetail;
    }

    public void setLedgerDetail(String ledgerDetail) {
        this.ledgerDetail = ledgerDetail;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }
}
